package com.woniu.humanresource.utils;

import org.apache.commons.codec.binary.Base64;

import java.io.File;
import java.io.FileInputStream;

//图片转换为base64格式
public class Base64Util {
    public static String getBase64(File file){
        byte[] bytes=null;
        FileInputStream fis=null;
        try {
            fis=new FileInputStream(file);
            bytes=new byte[fis.available()];
            fis.read(bytes);
            fis.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new String(Base64.encodeBase64(bytes));
    }
}
